<?php
    // new cat
    class NewsModels
    {
        public function __construct(PDO $pdo) {
            $this->pdo = $pdo;
        }
        public function getAllNews()
        {
            $sql = "SELECT * FROM set_news";
            $sth = $this->pdo->prepare($sql);
            $sth->execute();
            $result = $sth->fetchAll();
            return $result;            
        }
        public function getNewsByID($id)
        {
            $sql = "SELECT * FROM set_news WHERE ID_NEWS=$id limit 1";
            $sth = $this->pdo->prepare($sql);
            $sth->execute();
            $result = $sth->fetch();
            return $result;            
        }       
    }
